home *** CD-ROM | disk | FTP | other *** search
- class KidMc extends GameObject
- {
- var sweat;
- var pose;
- var engine;
- var exclamation;
- var stamina;
- var kid;
- var onPress;
- var onRollOver;
- var onDragOver;
- var onRollOut;
- var onDragOut;
- var inner;
- var isDownHill;
- var isOver = false;
- static var POSE_BUFFER = 0.1;
- static var DOWN = "forward";
- static var UP = "back";
- static var SIDE = "side";
- static var IDLE = "idle";
- static var RIGHT = "right";
- static var LEFT = "left";
- static var OK = "ok";
- static var TIRED = "tired";
- static var KNACKERED = "knackered";
- static var SWEAT = "sweat";
- static var NO_SWEAT = "noSweat";
- var dir = KidMc.DOWN;
- function KidMc()
- {
- super();
- this.stop();
- this.sweat.stop();
- this.pose = [KidMc.LEFT,KidMc.IDLE];
- this.init(this.engine);
- }
- function onLoad()
- {
- this.exclamation.init(this.engine);
- this.stamina.init(this.engine);
- }
- function update()
- {
- super.update();
- this.stamina.update(this.kid.stamina / this.kid.maxStamina);
- if(!this.kid.happy && !this.kid.knackered)
- {
- var _loc4_ = (1 - this.kid.stamina / this.kid.maxStamina - Kid.TIRED_POINT) * (1 / Kid.EXHAUSTED_POINT);
- var _loc3_ = 1 + Math.floor(_loc4_ * this.exclamation.inner.inner._totalframes);
- this.exclamation.inner.inner.gotoAndStop(_loc3_);
- }
- this.exclamation.convertScale();
- }
- function joinedPump()
- {
- this.onPress = this.doLeavePump;
- this.onRollOver = this.onDragOver = this.rolledOver;
- this.onRollOut = this.onDragOut = this.rolledOut;
- }
- function leftPump()
- {
- delete this.onPress;
- delete this.onRollOver;
- delete this.onRollOut;
- delete this.onDragOver;
- delete this.onDragOut;
- this.rolledOut();
- }
- function rolledOver()
- {
- this.inner.filters = [GameObject.GLOW_FILTER];
- this.stamina._visible = true;
- this.isOver = true;
- }
- function rolledOut()
- {
- this.inner.filters = [];
- this.stamina._visible = false;
- this.isOver = false;
- }
- function doLeavePump()
- {
- this.kid.leavePump(true);
- }
- function getPoseForAng(ang)
- {
- var _loc1_ = 0.5235987755982988;
- if(ang > - _loc1_ * 5 && ang <= - _loc1_ * 3)
- {
- return [KidMc.LEFT,KidMc.UP];
- }
- if(ang > - _loc1_ * 3 && ang <= - _loc1_)
- {
- return [KidMc.RIGHT,KidMc.UP];
- }
- if(ang > - _loc1_ && ang <= _loc1_)
- {
- return [KidMc.RIGHT,KidMc.SIDE];
- }
- if(ang > _loc1_ && ang <= _loc1_ * 3)
- {
- return [KidMc.RIGHT,KidMc.DOWN];
- }
- if(ang > _loc1_ * 3 && ang <= _loc1_ * 5)
- {
- return [KidMc.LEFT,KidMc.DOWN];
- }
- return [KidMc.LEFT,KidMc.SIDE];
- }
- function doChangePose(ang, pose)
- {
- var _loc1_ = 0.5235987755982988;
- switch(pose.join(""))
- {
- case KidMc.LEFT + KidMc.UP:
- return !(ang + KidMc.POSE_BUFFER > - _loc1_ * 5 && ang - KidMc.POSE_BUFFER <= - _loc1_ * 3);
- case KidMc.RIGHT + KidMc.UP:
- return !(ang + KidMc.POSE_BUFFER > - _loc1_ * 3 && ang - KidMc.POSE_BUFFER <= - _loc1_);
- case KidMc.RIGHT + KidMc.SIDE:
- return !(ang + KidMc.POSE_BUFFER > - _loc1_ && ang - KidMc.POSE_BUFFER <= _loc1_);
- case KidMc.RIGHT + KidMc.DOWN:
- return !(ang + KidMc.POSE_BUFFER > _loc1_ && ang - KidMc.POSE_BUFFER <= _loc1_ * 3);
- case KidMc.LEFT + KidMc.DOWN:
- return !(ang + KidMc.POSE_BUFFER > _loc1_ * 3 && ang - KidMc.POSE_BUFFER <= _loc1_ * 5);
- case KidMc.LEFT + KidMc.SIDE:
- return true;
- default:
- return true;
- }
- }
- function setPos(p)
- {
- if(p.x != this._x || p.y != this._y)
- {
- var _loc3_ = undefined;
- if(!this.isDownHill)
- {
- _loc3_ = Math.atan2(- (p.y - this._y),p.x - this._x);
- }
- else
- {
- _loc3_ = Math.atan2(p.y - this._y,p.x - this._x);
- }
- if(this.doChangePose(_loc3_,this.pose))
- {
- this.pose = this.getPoseForAng(_loc3_);
- if(this.pose[0] == KidMc.LEFT)
- {
- this.xdir = -1;
- }
- else
- {
- this.xdir = 1;
- }
- var _loc4_ = this.pose[1];
- if(this.dir != _loc4_)
- {
- this.setPose(_loc4_);
- }
- }
- this._x = p.x;
- this._y = p.y;
- this.swapDepths(this.getTargetDepth());
- }
- else if(this.dir != KidMc.IDLE)
- {
- this.setPose(KidMc.IDLE);
- }
- }
- function startSweating()
- {
- this.exclamation.setState(KidMc.TIRED);
- this.sweat.gotoAndPlay(KidMc.SWEAT);
- }
- function stopSweating()
- {
- this.exclamation.setState(KidMc.OK);
- this.sweat.gotoAndStop(KidMc.NO_SWEAT);
- }
- function changeKnackered(isKnackered)
- {
- if(isKnackered)
- {
- this.exclamation.setState(KidMc.KNACKERED);
- }
- else
- {
- this.exclamation.setState(KidMc.OK);
- }
- this.setPose(this.dir);
- }
- function setPose(newDir)
- {
- this.dir = newDir;
- this.gotoAndStop((!(this.kid.knackered && !this.kid.leaving) ? "" : KidMc.KNACKERED) + newDir);
- this.kid.setAvatar();
- if(this.isOver)
- {
- this.rolledOver();
- }
- }
- }
-